import { subtract, multiply, floor } from 'lodash';

const calcRectSize = (sx, sy, ex, ey, zoom = 1) => {
  const x = sx <= ex ? sx : ex;
  const y = sy <= ey ? sy : ey;
  const width = sx <= ex ? subtract(ex - sx) : subtract(sx - ex);
  const height = sy <= ey ? subtract(ey - sy) : subtract(sy - ey);
  return {
    x: floor(multiply(x, zoom)),
    y: floor(multiply(y, zoom)),
    width: floor(multiply(width, zoom)),
    height: floor(multiply(height, zoom)),
  };
};

export default calcRectSize;
